import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

const publicKey = '-----BEGIN PUBLIC KEY-----\n' +
    'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDHc+PP8LuTlBL1zCX+lh9kcur\n' +
    'gHHIXFnV/tDK789DaJuhwZvQ1lu5Zdcn+ULbNUKkB6b5tCP0sZxlpoCVKMyKHtde\n' +
    'h/YGXwBD8sMc+XcRs0eh3/tyr4EoBu3bomzHWDGmHjH/F5GotFTrGcB6xQwAROy4\n' +
    'mT5SketlQ3c7tucI+QIDAQAB\n' +
    '-----END PUBLIC KEY-----' //公钥
// 加密
export function encrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPublicKey(publicKey) // 设置公钥
    return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}